package com.problem.leetcode;

import com.google.common.base.Stopwatch;

/**
 * @author didi
 * @DESCRIPTION
 * @create 2019-05-09 00:23
 **/

public class Problem459 {
    public boolean repeatedSubstringPattern(String s) {
        int length = s.length();
        if ((length & 0x1) == 1) {
            return false;
        }

        int begin = 0, second = length >> 1;
        while (second < length) {
            if (s.charAt(begin++) != s.charAt(second++)) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Stopwatch stopwatch = Stopwatch.createStarted();
        Problem459 problem459 = new Problem459();
        for (int index = 0; index < 10000000; index++) {
            problem459.repeatedSubstringPattern("abcabcabcabc");
        }
        stopwatch.stop();
        System.out.println(stopwatch.toString());
    }
}
